#ifndef __HUMAN_PICTURE_H__
#define __HUMAN_PICTURE_H__

#include <string>
#include <vector>
#include <cv.h>

#include "Picture.h"

using namespace std;

class HumanPicture : public Picture {
    public:
        typedef vector<cv::Rect> Faces;
        typedef vector<cv::Rect> Bodies;

        /* HumanPicture c'tor;
         * Gets a picture and a cascade xml file */
        HumanPicture (const string& pic, const string& cacade);
    
        /* fetchFaces iddentified faces in picture according
         * the cascade provided int the c'tor
         * if faces already calculated, it will not perform the
         * detection again.
         * @return read only refference to the private vector */
        const Faces& fetchFaces();
  
        /* fetchBodies uses fetchFaces to identify bodies pictures.
         * @returns a read only refference to the private vector */
        const Bodies& fetchBodies();
        
        /* dump faces pictures to disk */
        void dumpFaces();
    private:
        /* Will use this cascade in the detection process */
        cv::CascadeClassifier facesCascade;
        /* The matrix that the detection will run over */
        cv::Mat faceSearchImage;
        /* vectors of rectagles that holds the ROI */
        vector<cv::Rect> facesList;
        vector<cv::Rect> bodiesList;
        bool initialized;
        /* Keep a state, so we don't have to populate everytime. */
        bool facesPopulated;
        /* Keep a state, so we don't have to populate everytime. */
        bool bodiesPopulated;
    
        /* no default copy c'tors */
        HumanPicture(const HumanPicture& p);
        HumanPicture& operator=(const HumanPicture& p);
        /* init the object, so the object will be valid even if init is unsccefull 
         * @returns false incase the initialization was unsuccesful */
        bool init(const std::string& cascade);  
        /* read cascade and save faces in facesList; 
         * succuful execution will flag the facesPopulated property */
        bool populateFaces();
        /* call populateFaces and populate bodiesList; 
         * successfu execution will flag the bodiesPopulated property */
        bool populateBodies();
};


#endif // __HUMAN_PICTURE_H__
